import { method } from 'lodash';
import { request,downloadFile } from '/@/utils/service';
import { PageQuery, AddReq, DelReq, EditReq, InfoReq } from '@fast-crud/fast-crud';
import { data } from 'autoprefixer';
import { Session } from '/@/utils/storage';
import { url } from 'inspector';

export const apiPrefix = '/api/CaseInfoModelViewSet/';

export function GetList(query: PageQuery) {
	return request({
		url: apiPrefix,
		method: 'get',
		params: query,
	});
}
export function GetObj(id: InfoReq) {
	return request({
		url: apiPrefix + id,
		method: 'get',
	});
}

export function AddObj(obj: AddReq) {
	return request({
		url: apiPrefix,
		method: 'post',
		data: obj,
	});
}

export function UpdateObj(obj: EditReq) {
	return request({
		url: apiPrefix + obj.id + '/',
		method: 'put',
		data: obj,
	});
}

export function DelObj(id: DelReq) {
	return request({
		url: apiPrefix + id + '/',
		method: 'delete',
		data: { id },
	});
}

export function exportData(params:any){
    return downloadFile({
        url: apiPrefix + 'export_data/',
        params: params,
        method: 'get'
    })
}

// 批量分组
export function batchGroup(params:any){
	return request({
		url:'/api/groupings/',
		method:'post',
		data:params
	});
}

// 导入案件列表
export function importData(params:any){
	const token = Session.get('token');
	return request({
		url:'/api/FileViewSet/',
		method:'post',
		headers: {'Content-Type': 'multipart/form-data','Authorization':'JWT ' + token},
		data:params
	});
}

// 导出起诉状
export function exportIndictment(params:any){
	return request({
		url:'/api/prosecution/',
		method:'post',
		data:params
	});
}
// 余额构成表
export function exportBalanceData(params:any){
	return request({
		url:'/api/balance/',
		method:'post',
		data:params
	});
}
// 委托授权书导出
export function exportEntrustData(params:any){
	return request({
		url:'/api/entrust/',
		method:'post',
		data:params
	});
}

// 财产保全担保书
export function exportGuaranteeData(params:any){
	return request({
		url:'/api/guarantee/',
		method:'post',
		data:params
	});
}

// 财产担保书__线下冻结
export function exportGuaranteeFrozenData(params:any){
	return request({
		url:'/api/guarantee_frozen/',
		method:'post',
		data:params
	});
}

// 财产保全申请书
export function exportApplyData(params:any){
	return request({
		url:'/api/apply/',
		method:'post',
		data:params
	});
}

// 财产保全申请书_线下冻结
export function exportApplyFrozenData(params:any){
	return request({
		url:'/api/apply_frozen/',
		method:'post',
		data:params
	});
}

// 所函
export function exportGetlettersData(params:any){
	return request({
		url:'/api/getletters/',
		method:'post',
		data:params
	});
}

// 网络查控书
export function exportNetworkData(params:any){
	return request({
		url:'/api/network/',
		method:'post',
		data:params
	});
}